<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  author: Jsonor
  date: 2018/3/21 14:46
  description: Country view
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" %>
<html>
<head>
  <title>城市信息</title>
  <link rel="stylesheet" href="/static/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>

  <style>
    * {
      margin: auto;
      text-align: center;

    }
  </style>
</head>
<body>
<h1>城市信息</h1>
<div style="margin: 8px;">
  <form action="/searchCountry.action">
    Region : <input id="region" type="text" name="region">
    <input type="submit" value="搜索"/>
    <%--onclick="checkregion();"--%>
    <a href="/goadd.action" style="text-align: right">添加</a>
  </form>
</div>
<table border="1px solid black" style="align: center;font-size: 13px;">
  <tbody style="">
  <tr>
    <td>Count</td>
    <td>Code</td>
    <td>Name</td>
    <td>Region</td>
    <td>SurfaceArea</td>
    <td>IndepYear</td>
    <td>Population</td>
    <td>LifeExpectancy</td>
    <td>GNP</td>
    <td>HeadOfState</td>
    <td>Capital</td>
    <td>Code2</td>
    <td>Function</td>
  </tr>

  <c:forEach var="item" items="${page.list}" varStatus="vs">
    <tr>
      <td>${vs.count}</td>
      <td>${item.code}</td>
      <td>${item.name}</td>
      <td>${item.region}</td>
      <td>${item.surfaceArea}</td>
      <td>${item.indepYear}</td>
      <td>${item.population}</td>
      <td>
          ${item.lifeExpectancy}
      </td>
      <td>${item.gnp}</td>
      <td>${item.headOfState}</td>
      <td>${item.capital}</td>
      <td>${item.code2}</td>
      <td>
        <a href="/singlefind/${item.code}.action">修改</a>
        |
        <a href="javascript:;" onclick="already('${item.code}')">删除</a>
      </td>
    </tr>
  </c:forEach>
  </tbody>
</table>

<ul class="pagination">

  <li><a href="/searchfind/${page.pageNum - 1}/10/${region}.action">&laquo;</a></li>

  <c:forEach begin="${page.navigateFirstPage}" end="${page.navigateLastPage}" step="1" var="as">
    <c:if test="${as == page.pageNum}">
      <li class="active">
        <a href="/searchfind/${as}/10/${region}.action">${as}</a>
      </li>
    </c:if>
    <c:if test="${as != page.pageNum}">
      <li>
        <a href="/searchfind/${as}/10/${region}.action">${as}</a>
      </li>
    </c:if>
  </c:forEach>

  <li><a href="/searchfind/${page.pageNum + 1}/10/${region}.action">&raquo;</a></li>

</ul>
</body>

<script type="text/javascript" src="/static/css/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script>

  function already(ev) {
    if (confirm("确定要删除吗")) {
      location = "/seardelete/" + ev + ".action";
    }
  }

  //  checkregion = function() {
  //      var region = $(":input[name='region']").val;
  //      if(region != null){
  //          location = "/pagesearchCountry.action?region="+ region;
  //      }else{
  //          location = "/pagefind.action?pageid=0";
  //      }
  //    }
</script>
</html>
